import React, { useEffect, useState } from 'react'
import axios from 'axios'
import { useNavigate, useSearchParams } from 'react-router-dom'
import { NavBar } from 'antd-mobile'
import styles from './css/list.module.css'

const List = () => {
    const nav= useNavigate()
     const [sp]= useSearchParams()
     const start=sp.get("start")
     const end=sp.get("end")
    const [list, setList] = useState([])
  const getData = async () => {
    const res = await axios.get("/api/trip/airplane",
         { params:{start, end} }
      )
    console.log(res.data.data);
    setList(res.data.data)
  }
  useEffect(() => {
    getData()
  }, [])
  return (
    <div>
      列表
      <NavBar onBack={()=> nav("/")}>{start}——{end}</NavBar>
      <div className={styles.box}>
       {
        list.map((v,i)=>{
            return <dl key={i} className={styles.dl}>
              <dt>
               <div>{v.dasn}</div>
               <div>{v.dt}</div>
              </dt>
              <dd>
                <div>{v.aat}</div>
               <div>{v.aasn}</div>
              </dd>
              <dd>
                <div>{v.at}</div>
               <div>{v.sc}</div>
              </dd>
            </dl>
        })
       }
      </div>
    </div>
  )
}

export default List
